﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Irony.Ast;
using Irony.Interpreter;
using Irony.Parsing;

namespace ConciseMarkupLanguage.Ast
{
    class StatementListNode : AstNode
    {
        public override void Init(ParsingContext context, ParseTreeNode treeNode)
        {
            base.Init(context, treeNode);
            foreach (var node in treeNode.ChildNodes)
                AddChild("statement", node);
        }

        public override void EvaluateNode(EvaluationContext context, AstMode mode)
        {
            var sb = new StringBuilder();
            foreach (var node in ChildNodes)
            {
                node.Evaluate(context, AstMode.Read);
                sb.Append(context.OutputBuffer);
                context.OutputBuffer.Clear();
            }
            context.OutputBuffer = sb;
        }
    }
}
